package com.micookie.v2ex.model.bean;

import android.os.Parcel;
import android.os.Parcelable;

import com.google.gson.annotations.SerializedName;

import org.greenrobot.greendao.annotation.Entity;
import org.greenrobot.greendao.annotation.Id;
import org.greenrobot.greendao.annotation.Generated;

/**
 * Created by Administrator on 2016/10/27.
 */

@Entity
public class Node implements Parcelable {

    @Id
    private Long id;

    /**
     * URL参数name
     */
    private String name;

    /**
     * 显示的标题
     */
    private String title;

    /**
     * 别名,一般是英文名或者中文名
     */
    @SerializedName("title_alternative")
    private String titleAlias;

    /**
     * URL
     */
    private String url;

    /**
     * 头像地址
     */
    @SerializedName("avatar_large")
    private String avatar_large;

    /**
     * 主题数量
     */
    @SerializedName("topics")
    private int topicCount;

    /**
     * 节点简介信息
     */
    private String header;

    /**
     * 创建时间
     */
    private int created;

    @Generated(hash = 1917039038)
    public Node(Long id, String name, String title, String titleAlias, String url,
                String avatar_large, int topicCount, String header, int created) {
        this.id = id;
        this.name = name;
        this.title = title;
        this.titleAlias = titleAlias;
        this.url = url;
        this.avatar_large = avatar_large;
        this.topicCount = topicCount;
        this.header = header;
        this.created = created;
    }

    @Generated(hash = 957215351)
    public Node() {
    }

    protected Node(Parcel in) {
        name = in.readString();
        title = in.readString();
        titleAlias = in.readString();
        url = in.readString();
        avatar_large = in.readString();
        topicCount = in.readInt();
        header = in.readString();
        created = in.readInt();
    }

    public static final Creator<Node> CREATOR = new Creator<Node>() {
        @Override
        public Node createFromParcel(Parcel in) {
            return new Node(in);
        }

        @Override
        public Node[] newArray(int size) {
            return new Node[size];
        }
    };

    public String getHeader() {
        return header == null ? "" : header;
    }

    public Node setHeader(String header) {
        this.header = header;
        return this;
    }

    public int getCreated() {
        return created;
    }

    public Node setCreated(int created) {
        this.created = created;
        return this;
    }

    public String getName() {
        return name;
    }

    public Node setName(String name) {
        this.name = name;
        return this;
    }

    public String getTitle() {
        return title == null ? "" : title;
    }

    public Node setTitle(String title) {
        this.title = title;
        return this;
    }

    public String getTitleAlias() {
        return titleAlias;
    }

    public Node setTitleAlias(String titleAlias) {
        this.titleAlias = titleAlias;
        return this;
    }

    public String getUrl() {
        return url;
    }

    public Node setUrl(String url) {
        this.url = url;
        return this;
    }


    public String getAvatar_large() {
        return avatar_large;
    }

    public Node setAvatar_large(String avatar_large) {
        this.avatar_large = avatar_large;
        return this;
    }


    public int getTopicCount() {
        return topicCount;
    }

    public String getTopicCountString() {
        return String.valueOf(topicCount);
    }

    public Node setTopicCount(int topicCount) {
        this.topicCount = topicCount;
        return this;
    }

    public Long getId() {
        return this.id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(name);
        dest.writeString(title);
        dest.writeString(titleAlias);
        dest.writeString(url);
        dest.writeString(avatar_large);
        dest.writeInt(topicCount);
        dest.writeString(header);
        dest.writeInt(created);
    }
}

